package com.eleven.controller;

import java.util.List;

import javax.validation.constraints.Pattern;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eleven.pojo.Msg;
import com.eleven.pojo.Projects;
import com.eleven.service.ProjectsReceptionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Controller
public class ProjectsReceptionController {
	@Autowired
	ProjectsReceptionService ProjectsReceptionService;
	/**
	 * 获取每种公益类型下众筹中的项目详情信息
	 * @param pstId 公益类型的唯一标识
	 * @param time
	 * @return
	 */
	@RequestMapping("/projectsgylxzcz")
	@ResponseBody
	public Msg getProjectsGylxZcz(Integer pstId,String time) {
		PageHelper.startPage(1,6);
		List<Projects> list = ProjectsReceptionService.getProjectsGylxZcz(pstId);
		PageInfo pageInfo = new PageInfo(list,1);
		return Msg.success().add("projectsGylxZcz", pageInfo);
	}
	/**
	 * 获取审核中和项目成功的公益类型项目
	 * @param type 项目的状态
	 * @return
	 */
	@RequestMapping(value="/projectsType/{type}",method=RequestMethod.GET)
	@ResponseBody
	public Msg getProjectsType(@PathVariable("type")Integer type) {
		PageHelper.startPage(1,4);
		List<Projects> list = ProjectsReceptionService.getProjectsType(type);
		PageInfo pageInfo = new PageInfo(list,1);
		return Msg.success().add("projectsType", list);
	}
	/**
	 * 根据条件进行项目的查询
	 * @param pn  页数
	 * @param pstId 公益类型
	 * @param zmztValue  项目状态
	 * @param xmptValue  项目排序
	 * @param time 随机数
	 * @return
	 */
	@RequestMapping("/gylxprojects")
	@ResponseBody
	public Msg getGylxprojects(@RequestParam(value="pn",defaultValue="1")Integer pn,
			Integer pstId,Integer zmztValue,Integer xmpxValue,String time) {
		PageHelper.startPage(pn,4);
		List<Projects> list = ProjectsReceptionService.getGylxprojects(pstId,zmztValue,xmpxValue);
		PageInfo pageInfo = new PageInfo(list,4);
		return Msg.success().add("gylxprojects", pageInfo);
	}
}
